﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using Global.Class.Library;
using DataAccessLayer;
using DataAccessLayer.ERmgrUIPTableAdapters;



namespace BusinessLogicLayer
{
    public class CommonMetaList
    {
        public ERmgrUIP.ListCustomerTypeDataTable GetCustomerType()
        {
            return GetCustomerType(false);
        }

        public ERmgrUIP.ListCustomerTypeDataTable GetCustomerType(bool withNewRow)
        {
            return GetCustomerType(withNewRow, "");
        }

        public ERmgrUIP.ListCustomerTypeDataTable GetCustomerType(bool withNewRow, string newRowDescription)
        {
            ListCustomerTypeTableAdapter listCustomerTypeTableAdapter = new ListCustomerTypeTableAdapter();
            ERmgrUIP.ListCustomerTypeDataTable listCustomerTypeDataTable = listCustomerTypeTableAdapter.GetData();

            if (withNewRow) listCustomerTypeDataTable.AddListCustomerTypeRow(newRowDescription, newRowDescription);
            return listCustomerTypeDataTable;
        }



        public ERmgrUIP.ListSalesmenNameDataTable GetSalesmenName()
        {
            return GetSalesmenName(false);
        }

        public ERmgrUIP.ListSalesmenNameDataTable GetSalesmenName(bool withNewRow)
        {
            ListSalesmenNameTableAdapter listSalesmenNameTableAdapter = new ListSalesmenNameTableAdapter();
            ERmgrUIP.ListSalesmenNameDataTable listSalesmenNameDataTable = listSalesmenNameTableAdapter.GetData();

            if (withNewRow) listSalesmenNameDataTable.AddListSalesmenNameRow("", "", 0, 0, 0);
            return listSalesmenNameDataTable;
        }


        public ERmgrUIP.ListOrderOrReturnDataTable GetOrderOrReturn()
        {
            return GetOrderOrReturn(false);
        }

        public ERmgrUIP.ListOrderOrReturnDataTable GetOrderOrReturn(bool withNewRow)
        {
            ListOrderOrReturnTableAdapter listOrderOrReturnTableAdapter = new ListOrderOrReturnTableAdapter();
            ERmgrUIP.ListOrderOrReturnDataTable listOrderOrReturnDataTable = listOrderOrReturnTableAdapter.GetData();

            if (withNewRow) listOrderOrReturnDataTable.AddListOrderOrReturnRow(0, "", "");
            return listOrderOrReturnDataTable;
        }


        public ERmgrUIP.ListDistributorNameDataTable GetDistributorName()
        {
            return GetDistributorName(false);
        }

        public ERmgrUIP.ListDistributorNameDataTable GetDistributorName(bool withNewRow)
        {
            ListDistributorNameTableAdapter listDistributorNameTableAdapter = new ListDistributorNameTableAdapter();
            ERmgrUIP.ListDistributorNameDataTable listDistributorNameDataTable = listDistributorNameTableAdapter.GetData();

            if (withNewRow) listDistributorNameDataTable.AddListDistributorNameRow(0, "", "", 0, 0, 0);
            return listDistributorNameDataTable;
        }


        public ERmgrUIP.ListPromotionCampaignDataTable GetPromotionCampaign()
        {
            return GetPromotionCampaign(false);
        }

        public ERmgrUIP.ListPromotionCampaignDataTable GetPromotionCampaign(bool withNewRow)
        {
            ListPromotionCampaignTableAdapter listPromotionCampaignTableAdapter = new ListPromotionCampaignTableAdapter();
            ERmgrUIP.ListPromotionCampaignDataTable listPromotionCampaignDataTable = listPromotionCampaignTableAdapter.GetData();

            if (withNewRow) listPromotionCampaignDataTable.AddListPromotionCampaignRow(0, "", "");
            return listPromotionCampaignDataTable;
        }


        public ERmgrUIP.ListCategoryReturnDataTable GetCategoryReturn()
        {
            return GetCategoryReturn(false);
        }

        public ERmgrUIP.ListCategoryReturnDataTable GetCategoryReturn(bool withNewRow)
        {
            ListCategoryReturnTableAdapter listCategoryReturnTableAdapter = new ListCategoryReturnTableAdapter();
            ERmgrUIP.ListCategoryReturnDataTable listCategoryReturnDataTable = listCategoryReturnTableAdapter.GetData();

            if (withNewRow) listCategoryReturnDataTable.AddListCategoryReturnRow(0, "", "");
            return listCategoryReturnDataTable;
        }


        public ERmgrUIP.ListCategoryRefuseDataTable GetCategoryRefuse()
        {
            return GetCategoryRefuse(false);
        }

        public ERmgrUIP.ListCategoryRefuseDataTable GetCategoryRefuse(bool withNewRow)
        {
            ListCategoryRefuseTableAdapter listCategoryRefuseTableAdapter = new ListCategoryRefuseTableAdapter();
            ERmgrUIP.ListCategoryRefuseDataTable listCategoryRefuseDataTable = listCategoryRefuseTableAdapter.GetData();

            if (withNewRow) listCategoryRefuseDataTable.AddListCategoryRefuseRow(0, "", "");
            return listCategoryRefuseDataTable;
        }


        public ERmgrUIP.ListStaffNameDataTable GetStaffName()
        {
            return GetStaffName(false);
        }

        public ERmgrUIP.ListStaffNameDataTable GetStaffName(bool withNewRow)
        {
            ListStaffNameTableAdapter listStaffNameTableAdapter = new ListStaffNameTableAdapter();
            ERmgrUIP.ListStaffNameDataTable listStaffNameDataTable = listStaffNameTableAdapter.GetData();

            if (withNewRow) listStaffNameDataTable.AddListStaffNameRow("", "");
            return listStaffNameDataTable;
        }



        public ERmgrUIP.ListAddressAreaDataTable GetAddressArea()
        {
            return GetAddressArea(false);
        }
        public ERmgrUIP.ListAddressAreaDataTable GetAddressArea(bool withNewRow)
        {
            return GetAddressArea(withNewRow, "");
        }

        public ERmgrUIP.ListAddressAreaDataTable GetAddressArea(bool withNewRow, string newRowDescription)
        {
            ListAddressAreaTableAdapter listAddressAreaTableAdapter = new ListAddressAreaTableAdapter();
            ERmgrUIP.ListAddressAreaDataTable listAddressAreaDataTable = listAddressAreaTableAdapter.GetData();

            if (withNewRow) listAddressAreaDataTable.AddListAddressAreaRow(newRowDescription);
            return listAddressAreaDataTable;
        }


        public ERmgrUIP.ListItemCategoryDataTable GetItemCategory()
        {
            return GetItemCategory(false);
        }

        public ERmgrUIP.ListItemCategoryDataTable GetItemCategory(bool withNewRow)
        {
            ListItemCategoryTableAdapter listItemCategoryTableAdapter = new ListItemCategoryTableAdapter();
            ERmgrUIP.ListItemCategoryDataTable listItemCategoryDataTable = listItemCategoryTableAdapter.GetData();

            if (withNewRow) listItemCategoryDataTable.AddListItemCategoryRow("");
            return listItemCategoryDataTable;
        }


        public ERmgrUIP.ListItemCommodityDataTable GetItemCommodity()
        {
            return GetItemCommodity(false);
        }

        public ERmgrUIP.ListItemCommodityDataTable GetItemCommodity(bool withNewRow)
        {
            ListItemCommodityTableAdapter listItemCommodityTableAdapter = new ListItemCommodityTableAdapter();
            ERmgrUIP.ListItemCommodityDataTable listItemCommodityDataTable = listItemCommodityTableAdapter.GetData();

            if (withNewRow) listItemCommodityDataTable.AddListItemCommodityRow("", "");
            return listItemCommodityDataTable;
        }



        public ERmgrUIP.ListCustomerChannelDataTable GetCustomerChannel()
        {
            return GetCustomerChannel(false, false);
        }

        public ERmgrUIP.ListCustomerChannelDataTable GetCustomerChannel(bool withNewRow)
        {
            return GetCustomerChannel(withNewRow, false);
        }

        public ERmgrUIP.ListCustomerChannelDataTable GetCustomerChannel(bool withNewRow, bool primaryChannelOnly)
        {
            ListCustomerChannelTableAdapter listCustomerChannelTableAdapter = new ListCustomerChannelTableAdapter();
            ERmgrUIP.ListCustomerChannelDataTable listCustomerChannelDataTable;
            if (primaryChannelOnly)
                listCustomerChannelDataTable = listCustomerChannelTableAdapter.GetPrimaryChannel();
            else
                listCustomerChannelDataTable = listCustomerChannelTableAdapter.GetData();

            if (withNewRow) listCustomerChannelDataTable.AddListCustomerChannelRow(" ");
            return listCustomerChannelDataTable;
        }


        public ERmgrUIP.ListCustomerNameDataTable GetCustomerName()
        {
            return GetCustomerName(false);
        }

        public ERmgrUIP.ListCustomerNameDataTable GetCustomerName(bool withNewRow)
        {
            return GetCustomerName(withNewRow, 0);
        }

        public ERmgrUIP.ListCustomerNameDataTable GetCustomerName(bool withNewRow, int customerID)
        {
            ListCustomerNameTableAdapter listCustomerNameTableAdapter = new ListCustomerNameTableAdapter();
            ERmgrUIP.ListCustomerNameDataTable listCustomerNameDataTable = customerID > 0? listCustomerNameTableAdapter.GetDataByCustomerID(customerID): listCustomerNameTableAdapter.GetData();

            if (withNewRow) listCustomerNameDataTable.AddListCustomerNameRow(" ", " ", 0, 0, 0, 0, 0);
            return listCustomerNameDataTable;
        }


        public ERmgrUIP.ListSupplierNameDataTable GetSupplierName()
        {
            return GetSupplierName(false);
        }

        public ERmgrUIP.ListSupplierNameDataTable GetSupplierName(bool withNewRow)
        {
            ListSupplierNameTableAdapter listSupplierNameTableAdapter = new ListSupplierNameTableAdapter();
            ERmgrUIP.ListSupplierNameDataTable listSupplierNameDataTable = listSupplierNameTableAdapter.GetData();

            if (withNewRow) listSupplierNameDataTable.AddListSupplierNameRow("", "");
            return listSupplierNameDataTable;
        }


        public ERmgrUIP.ListMarketingProgramGroupDataTable GetMarketingProgramGroup()
        {
            return GetMarketingProgramGroup(false);
        }

        public ERmgrUIP.ListMarketingProgramGroupDataTable GetMarketingProgramGroup(bool withNewRow)
        {
            ListMarketingProgramGroupTableAdapter listMarketingProgramGroupTableAdapter = new ListMarketingProgramGroupTableAdapter();
            ERmgrUIP.ListMarketingProgramGroupDataTable listMarketingProgramGroupDataTable = listMarketingProgramGroupTableAdapter.GetData();

            if (withNewRow) listMarketingProgramGroupDataTable.AddListMarketingProgramGroupRow(0, "");
            return listMarketingProgramGroupDataTable;
        }


        public ERmgrUIP.ListMarketingProgramTypeDataTable GetMarketingProgramType()
        {
            return GetMarketingProgramType(false);
        }

        public ERmgrUIP.ListMarketingProgramTypeDataTable GetMarketingProgramType(bool withNewRow)
        {
            ListMarketingProgramTypeTableAdapter listMarketingProgramTypeTableAdapter = new ListMarketingProgramTypeTableAdapter();
            ERmgrUIP.ListMarketingProgramTypeDataTable listMarketingProgramTypeDataTable = listMarketingProgramTypeTableAdapter.GetData();

            if (withNewRow) listMarketingProgramTypeDataTable.AddListMarketingProgramTypeRow(0, "");
            return listMarketingProgramTypeDataTable;
        }


        public ERmgrUIP.ListMarketingPaymentTypeDataTable GetMarketingPaymentType()
        {
            return GetMarketingPaymentType(false);
        }

        public ERmgrUIP.ListMarketingPaymentTypeDataTable GetMarketingPaymentType(bool withNewRow)
        {
            ListMarketingPaymentTypeTableAdapter listMarketingPaymentTypeTableAdapter = new ListMarketingPaymentTypeTableAdapter();
            ERmgrUIP.ListMarketingPaymentTypeDataTable listMarketingPaymentTypeDataTable = listMarketingPaymentTypeTableAdapter.GetData();

            if (withNewRow) listMarketingPaymentTypeDataTable.AddListMarketingPaymentTypeRow(0, "");
            return listMarketingPaymentTypeDataTable;
        }

        public ERmgrUIP.ListMarketingPaymentTermDataTable GetMarketingPaymentTerm()
        {
            return GetMarketingPaymentTerm(false);
        }

        public ERmgrUIP.ListMarketingPaymentTermDataTable GetMarketingPaymentTerm(bool withNewRow)
        {
            ListMarketingPaymentTermTableAdapter listMarketingPaymentTermTableAdapter = new ListMarketingPaymentTermTableAdapter();
            ERmgrUIP.ListMarketingPaymentTermDataTable listMarketingPaymentTermDataTable = listMarketingPaymentTermTableAdapter.GetData();

            if (withNewRow) listMarketingPaymentTermDataTable.AddListMarketingPaymentTermRow(0, "");
            return listMarketingPaymentTermDataTable;
        }


        public ERmgrUIP.ListItemTypeDataTable GetItemType()
        {
            return GetItemType(false);
        }

        public ERmgrUIP.ListItemTypeDataTable GetItemType(bool withNewRow)
        {
            ListItemTypeTableAdapter listItemTypeTableAdapter = new ListItemTypeTableAdapter();
            ERmgrUIP.ListItemTypeDataTable listItemTypeDataTable = listItemTypeTableAdapter.GetData();

            if (withNewRow) listItemTypeDataTable.AddListItemTypeRow("");
            return listItemTypeDataTable;
        }

        public ERmgrUIP.ListTimeBaseDataTable GetTimeBase()
        {
            return GetTimeBase(false);
        }

        public ERmgrUIP.ListTimeBaseDataTable GetTimeBase(bool withNewRow)
        {
            ListTimeBaseTableAdapter listTimeBaseTableAdapter = new ListTimeBaseTableAdapter();
            ERmgrUIP.ListTimeBaseDataTable listTimeBaseDataTable = listTimeBaseTableAdapter.GetData();

            if (withNewRow) listTimeBaseDataTable.AddListTimeBaseRow(0, "");
            return listTimeBaseDataTable;
        }


        public ERmgrUIP.ListMechanicSchemeDataTable GetMechanicScheme()
        {
            return GetMechanicScheme(false);
        }

        public ERmgrUIP.ListMechanicSchemeDataTable GetMechanicScheme(bool withNewRow)
        {
            ListMechanicSchemeTableAdapter listMechanicSchemeTableAdapter = new ListMechanicSchemeTableAdapter();
            ERmgrUIP.ListMechanicSchemeDataTable listMechanicSchemeDataTable = listMechanicSchemeTableAdapter.GetData();

            if (withNewRow) listMechanicSchemeDataTable.AddListMechanicSchemeRow(0, "", "");
            return listMechanicSchemeDataTable;
        }


        public ERmgrUIP.MarketingProgramListDataTable GetMarketingProgramList()
        {
            return GetMarketingProgramList(false);
        }

        public ERmgrUIP.MarketingProgramListDataTable GetMarketingProgramList(bool withNewRow)
        {
            MarketingProgramListTableAdapter marketingProgramListTableAdapter = new MarketingProgramListTableAdapter();
            ERmgrUIP.MarketingProgramListDataTable marketingProgramListDataTable = marketingProgramListTableAdapter.GetData();

            if (withNewRow) marketingProgramListDataTable.AddMarketingProgramListRow(" ", " ", " ");
            return marketingProgramListDataTable;
        }


        public ERmgrUIP.MarketingIncentiveMasterListDataTable GetMarketingIncentiveMasterList()
        {
            return GetMarketingIncentiveMasterList(false);
        }

        public ERmgrUIP.MarketingIncentiveMasterListDataTable GetMarketingIncentiveMasterList(bool withNewRow)
        {
            MarketingIncentiveMasterListTableAdapter MarketingIncentiveMasterListTableAdapter = new MarketingIncentiveMasterListTableAdapter();
            ERmgrUIP.MarketingIncentiveMasterListDataTable MarketingIncentiveMasterListDataTable = MarketingIncentiveMasterListTableAdapter.GetData();

            if (withNewRow) MarketingIncentiveMasterListDataTable.AddMarketingIncentiveMasterListRow(0, DateTime.Today, " ");
            return MarketingIncentiveMasterListDataTable;
        }


        public ERmgrUIP.ListItemPM_APMDataTable GetItemPM_APM()
        {
            return GetItemPM_APM(false);
        }

        public ERmgrUIP.ListItemPM_APMDataTable GetItemPM_APM(bool withNewRow)
        {
            ListItemPM_APMTableAdapter listItemPM_APMTableAdapter = new ListItemPM_APMTableAdapter();
            ERmgrUIP.ListItemPM_APMDataTable listItemPM_APMDataTable = listItemPM_APMTableAdapter.GetData();

            if (withNewRow) listItemPM_APMDataTable.AddListItemPM_APMRow("");
            return listItemPM_APMDataTable;
        }

        public ERmgrUIP.ListItemBrandDataTable GetItemBrand()
        {
            return GetItemBrand(false);
        }

        public ERmgrUIP.ListItemBrandDataTable GetItemBrand(bool withNewRow)
        {
            ListItemBrandTableAdapter listItemBrandTableAdapter = new ListItemBrandTableAdapter();
            ERmgrUIP.ListItemBrandDataTable listItemBrandDataTable = listItemBrandTableAdapter.GetData();

            if (withNewRow) listItemBrandDataTable.AddListItemBrandRow("");
            return listItemBrandDataTable;
        }


        public ERmgrUIP.ListItemGroupDataTable GetItemGroup()
        {
            return GetItemGroup(false);
        }

        public ERmgrUIP.ListItemGroupDataTable GetItemGroup(bool withNewRow)
        {
            ListItemGroupTableAdapter listItemGroupTableAdapter = new ListItemGroupTableAdapter();
            ERmgrUIP.ListItemGroupDataTable listItemGroupDataTable = listItemGroupTableAdapter.GetData();

            if (withNewRow) listItemGroupDataTable.AddListItemGroupRow("");
            return listItemGroupDataTable;
        }


        public ERmgrUIP.ListItemClassDataTable GetItemClass()
        {
            return GetItemClass(false);
        }

        public ERmgrUIP.ListItemClassDataTable GetItemClass(bool withNewRow)
        {
            ListItemClassTableAdapter listItemClassTableAdapter = new ListItemClassTableAdapter();
            ERmgrUIP.ListItemClassDataTable listItemClassDataTable = listItemClassTableAdapter.GetData();

            if (withNewRow) listItemClassDataTable.AddListItemClassRow("");

            return listItemClassDataTable;
        }


        public ERmgrUIP.ListCustomerCategoryDataTable GetCustomerCategory()
        {
            return GetCustomerCategory(false);
        }

        public ERmgrUIP.ListCustomerCategoryDataTable GetCustomerCategory(bool withNewRow)
        {
            ListCustomerCategoryTableAdapter listCustomerCategoryTableAdapter = new ListCustomerCategoryTableAdapter();
            ERmgrUIP.ListCustomerCategoryDataTable listCustomerCategoryDataTable = listCustomerCategoryTableAdapter.GetData();

            if (withNewRow) listCustomerCategoryDataTable.AddListCustomerCategoryRow("");
            return listCustomerCategoryDataTable;
        }


        public ERmgrUIP.ListItemPriceCategoryDataTable GetItemPriceCategory()
        {
            return GetItemPriceCategory(false);
        }

        public ERmgrUIP.ListItemPriceCategoryDataTable GetItemPriceCategory(bool withNewRow)
        {
            ListItemPriceCategoryTableAdapter listItemPriceCategoryTableAdapter = new ListItemPriceCategoryTableAdapter();
            ERmgrUIP.ListItemPriceCategoryDataTable listItemPriceCategoryDataTable = listItemPriceCategoryTableAdapter.GetData();

            if (withNewRow) listItemPriceCategoryDataTable.AddListItemPriceCategoryRow(0, "", "");
            return listItemPriceCategoryDataTable;
        }

        public ERmgrUIP.ListCustomerGroupDataTable GetCustomerGroup()
        {
            return GetCustomerGroup(false);
        }

        public ERmgrUIP.ListCustomerGroupDataTable GetCustomerGroup(bool withNewRow)
        {
            ListCustomerGroupTableAdapter listCustomerGroupTableAdapter = new ListCustomerGroupTableAdapter();
            ERmgrUIP.ListCustomerGroupDataTable listCustomerGroupDataTable = listCustomerGroupTableAdapter.GetData();

            if (withNewRow) listCustomerGroupDataTable.AddListCustomerGroupRow("");
            return listCustomerGroupDataTable;
        }


        public ERmgrUIP.ListSalesmenCategoryDataTable GetSalesmenCategory()
        {
            return GetSalesmenCategory(false);
        }

        public ERmgrUIP.ListSalesmenCategoryDataTable GetSalesmenCategory(bool withNewRow)
        {
            ListSalesmenCategoryTableAdapter listSalesmenCategoryTableAdapter = new ListSalesmenCategoryTableAdapter();
            ERmgrUIP.ListSalesmenCategoryDataTable listSalesmenCategoryDataTable = listSalesmenCategoryTableAdapter.GetData();

            if (withNewRow) listSalesmenCategoryDataTable.AddListSalesmenCategoryRow("");
            return listSalesmenCategoryDataTable;
        }


        public ERmgrUIP.ListSalesmenTypeDataTable GetSalesmenType()
        {
            return GetSalesmenType(false);
        }

        public ERmgrUIP.ListSalesmenTypeDataTable GetSalesmenType(bool withNewRow)
        {
            ListSalesmenTypeTableAdapter listSalesmenTypeTableAdapter = new ListSalesmenTypeTableAdapter();
            ERmgrUIP.ListSalesmenTypeDataTable listSalesmenTypeDataTable = listSalesmenTypeTableAdapter.GetData();

            if (withNewRow) listSalesmenTypeDataTable.AddListSalesmenTypeRow("");
            return listSalesmenTypeDataTable;
        }


        public ERmgrUIP.ListSalesmenTitleDataTable GetSalesmenTitle()
        {
            return GetSalesmenTitle(false);
        }

        public ERmgrUIP.ListSalesmenTitleDataTable GetSalesmenTitle(bool withNewRow)
        {
            ListSalesmenTitleTableAdapter listSalesmenTitleTableAdapter = new ListSalesmenTitleTableAdapter();
            ERmgrUIP.ListSalesmenTitleDataTable listSalesmenTitleDataTable = listSalesmenTitleTableAdapter.GetData();

            if (withNewRow) listSalesmenTitleDataTable.AddListSalesmenTitleRow("");
            return listSalesmenTitleDataTable;
        }


        public ERmgrUIP.ListStaffCategoryDataTable GetStaffCategory()
        {
            return GetStaffCategory(false);
        }

        public ERmgrUIP.ListStaffCategoryDataTable GetStaffCategory(bool withNewRow)
        {
            ListStaffCategoryTableAdapter listStaffCategoryTableAdapter = new ListStaffCategoryTableAdapter();
            ERmgrUIP.ListStaffCategoryDataTable listStaffCategoryDataTable = listStaffCategoryTableAdapter.GetData();

            if (withNewRow) listStaffCategoryDataTable.AddListStaffCategoryRow("");
            return listStaffCategoryDataTable;
        }


        public ERmgrUIP.ListDistributorCategoryDataTable GetDistributorCategory()
        {
            return GetDistributorCategory(false);
        }

        public ERmgrUIP.ListDistributorCategoryDataTable GetDistributorCategory(bool withNewRow)
        {
            ListDistributorCategoryTableAdapter listDistributorCategoryTableAdapter = new ListDistributorCategoryTableAdapter();
            ERmgrUIP.ListDistributorCategoryDataTable listDistributorCategoryDataTable = listDistributorCategoryTableAdapter.GetData();

            if (withNewRow) listDistributorCategoryDataTable.AddListDistributorCategoryRow("");
            return listDistributorCategoryDataTable;
        }


        public ERmgrUIP.ListDistributorTypeDataTable GetDistributorType()
        {
            return GetDistributorType(false);
        }

        public ERmgrUIP.ListDistributorTypeDataTable GetDistributorType(bool withNewRow)
        {
            ListDistributorTypeTableAdapter listDistributorTypeTableAdapter = new ListDistributorTypeTableAdapter();
            ERmgrUIP.ListDistributorTypeDataTable listDistributorTypeDataTable = listDistributorTypeTableAdapter.GetData();

            if (withNewRow) listDistributorTypeDataTable.AddListDistributorTypeRow("");
            return listDistributorTypeDataTable;
        }

    }
}
